package com.gec.zhs.utils;

/**
 * @author zhs
 * @version 1.0
 * @date 2025-08-25
 * @description
 */
public enum ResultCodeEnum {

    SUCCESS(200,"成功"),
    FAIL(500,"失败"),
    PARAM_ERROR(400,"参数错误"),
    SERVICE_ERROR(500,"服务异常"),

    USER_NOT_LOGIN(50001,"用户未登录");
    private Integer code;
    private String msg;

    ResultCodeEnum(){}

    ResultCodeEnum(Integer code, String msg){
        this.code = code;
        this.msg = msg;
    }

    public Integer getCode() {
        return this.code;
    }

    public String getMsg() {
        return this.msg;
    }

    public static String getMsgByCode(Integer code){
        for (ResultCodeEnum value : ResultCodeEnum.values()) {
            if(value.code.equals(code)){
                return value.msg;
            }
        }
        return "";
    }

    public static Integer getCodeByMsg(String msg){
        for (ResultCodeEnum value : ResultCodeEnum.values()) {
            if(value.msg.equals(msg)){
                return value.code;
            }
        }
        return null;
    }
}
